<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>列表渲染</title>
</head>
<style>
    *{
        padding:0;
        margin:0;
        list-style:none;

    }
    [v-cloak]{
        display: none;
    }
    .tb{
        width: 500px;
        border:1px solid gray;
        border-collapse:collapse;
    }
    .tb td,
    .tb th{
        text-align: center;
        border-bottom: 1px solid gray;
    }



</style>
<body>
    <div id="app" v-cloak>
        <table class="tb">
            <tr>
                <th>序号</th>
                <th>编码</th>
                <th>昵称</th>
                <th>类型</th>
                <th>操作</th>
            </tr>
            <tr v-for="(item,i) in list " :key="i">
               <td>{{i+1}}</td>
               <td>{{item.id}}</td>
               <td>{{item.name}}</td>
               <td>{{item.type}}</td>
               <td><button  @click="del(item.id)">删除</button></td>
            </tr>
        </table>

    </div>
    <script src="js/vue.js"></script>
    <script>
        Vue.config.devtools =false
        Vue.config.productionTip =false 
        new Vue({
            el:"#app",
            data(){
                return{
                    list:[{
                    id: 1001,
                    name: "小黑",
                    type: "狗"
                }, {
                    id: 1002,
                    name: "小红",
                    type: "猫"
                }, {
                    id: 1003,
                    name: "小绿",
                    type: "狗"
                }]

                }
            },
            methods:{
                del(id){
                  this.list= this.list.filter(item=>{
                        item.id !==id
                    })
                }
            }
        })
    
    
    
    </script>
</body>
</html>